<?php
/**
 * --------------------------------
 * # 自动载入类文件
 * --------------------------------
 * 1. 2017
 * --------------------------------
 */
namespace phpless\core;

class Autoloader
{
    public static $classMap=array();
    // 自动加载类库
    static public function load($class)
    {
        if(isset(self::$classMap[$class])){
            return true;
        }else{
            $class=str_replace('\\', '/', $class);
            $file=APP.DIRECTORY_SEPARATOR.$class.'.class.php';
            if(is_file($file)){
                include $file;
                self::$classMap[$class]=$class;
            }else{
                $trait_file=APP.DIRECTORY_SEPARATOR.$class.'.trait.php';
                if(is_file($trait_file)){
                    include $trait_file;
                    self::$classMap[$class]=$class;
                }
                return false;
            }
        }
    }
}
